package com.eachonline.smart.web.article;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.eachonline.core.JsonResult;
import com.eachonline.core.Pagination;
import com.eachonline.oss.OssConstant;
import com.eachonline.oss.OssService;
import com.eachonline.smart.mapper.SmartSupportRelateMapper;
import com.eachonline.smart.model.SmartArtcile;
import com.eachonline.smart.model.SmartArtcileExample;
import com.eachonline.smart.model.SmartSupportRelate;
import com.eachonline.smart.model.SmartSupportRelateExample;
import com.eachonline.smart.model.SmartUser;
import com.eachonline.smart.model.SysCourseCategory;
import com.eachonline.smart.model.SysCourseCategoryExample;
import com.eachonline.smart.model.base.BaseSysCourseCategoryExample.Criteria;
import com.eachonline.smart.service.ArticleService;
import com.eachonline.smart.service.SmartUserService;
import com.eachonline.smart.service.SysCourseCategoryService;
import com.eachonline.smart.web.common.CommonUtil;
import com.eachonline.util.StringUtil;
import com.eachonline.util.UUIDUtil;

@Controller
@RequestMapping("/article")
public class ArticleController{
	
	@Resource
	private ArticleService articleService;

	@Autowired
	public  SysCourseCategoryService  sysCourseService;
	
	@Resource
	private SmartUserService userService;
	
	@Resource
	private OssService ossService;
	
	@Resource
	private SmartSupportRelateMapper supportRelateMapper;
	/**
	 * 查询列表
	 * @param start
	 * @param pageSize
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/queryArticleList",method = RequestMethod.POST)
	public JsonResult queryHotArticleList(HttpServletRequest request,String site,String articleName,String teacherId,String articleCategoryCode){
		int start=1;
		if(StringUtil.isNotEmpty(request.getParameter("start")))
		{
		  start=Integer.valueOf(request.getParameter("start").toString());
		}
		
		int pageSize=8;
		if(StringUtil.isNotEmpty(request.getParameter("pageSize")))
		{
			pageSize=Integer.valueOf(request.getParameter("pageSize").toString());
		}
		int begin =pageSize*(start-1);
		
		Pagination<SmartArtcile> artcilePageInfo= articleService.queryArticleList(begin, pageSize, site, articleName, teacherId,articleCategoryCode);
		Map<String,Object> resultMap=new HashMap<String, Object>();
		resultMap.put("artcileList", artcilePageInfo.getDataList());
		resultMap.put("sumRow", artcilePageInfo.getTotalRowNumber());
		return new JsonResult(true, "成功", resultMap);
	 
	}
	
	
	/**
	 * 查询列表
	 * @param start
	 * @param pageSize
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/queryHomeArticleList",method = RequestMethod.POST)
	public JsonResult queryHomeArticleList(HttpServletRequest request,String site,String articleName,String articleCategoryCode){
		int start=1;
		if(StringUtil.isNotEmpty(request.getParameter("start")))
		{
		  start=Integer.valueOf(request.getParameter("start").toString());
		}
		
		int pageSize=5;
		if(StringUtil.isNotEmpty(request.getParameter("pageSize")))
		{
			pageSize=Integer.valueOf(request.getParameter("pageSize").toString());
		}
		int begin =pageSize*(start-1);
		
		SmartArtcileExample exa1=new SmartArtcileExample();
		exa1.createCriteria().andArticleCategoryCodeLike("400101%").andCheckStatusEqualTo("2");
		Pagination<SmartArtcile> page101Info= articleService.queryByPage(exa1, begin, pageSize," create_time desc");
		SmartArtcileExample exa2=new SmartArtcileExample();

		exa2.createCriteria().andArticleCategoryCodeLike("400102%").andCheckStatusEqualTo("2");
		Pagination<SmartArtcile> pageI102nfo= articleService.queryByPage(exa2, begin, pageSize," create_time desc");
		SmartArtcileExample exa3=new SmartArtcileExample();
		exa3.createCriteria().andArticleCategoryCodeLike("400103%").andCheckStatusEqualTo("2");
		Pagination<SmartArtcile> page103Info= articleService.queryByPage(exa3, begin, pageSize," create_time desc");
		SmartArtcileExample exa4=new SmartArtcileExample();
		exa4.createCriteria().andArticleCategoryCodeLike("400104%").andCheckStatusEqualTo("2");
		Pagination<SmartArtcile> page104Info= articleService.queryByPage(exa4, begin, pageSize," create_time desc");
		
		Map<String,Object> resultMap=new HashMap<String, Object>();
		resultMap.put("lastList", page101Info.getDataList());
		resultMap.put("softList", pageI102nfo.getDataList());
		resultMap.put("hardwareList", page103Info.getDataList());
		resultMap.put("ueList", page104Info.getDataList());
		return new JsonResult(true, "成功", resultMap);
	 
	 
	}
	
	
	/**
	 * 文章点赞点赞
	 * @param start
	 * @param pageSize
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/supportArticle",method = RequestMethod.POST)
	public JsonResult supportArticle(HttpServletRequest request,String articleId,String userId,int su,HttpServletResponse  response){
		response.setHeader("Access-Control-Allow-Origin", "*");
		response.setHeader("Access-Control-Allow-Methods", "POST");
		  
		if(su==1)
		{
			  SmartSupportRelateExample  sre=new SmartSupportRelateExample();
			  sre.createCriteria().andBusinessIdEqualTo(articleId).andUserIdEqualTo(userId);
			  List<SmartSupportRelate>  list= supportRelateMapper.selectByExample(sre);
			  if(!list.isEmpty())
			  {
				  return new JsonResult(false, "该文章已经点赞过，不能重复点赞");
			  }
			
			SmartArtcile article=articleService.selectByPrimaryKey(articleId);
			
			if(article==null)
			{
				return new JsonResult(false, "该文章不存在");
			}
			int supportNum=article.getSupportNum()+su;
			
			if(supportNum<=0)
			{
				supportNum=0;
			}
			article.setSupportNum(supportNum);	
			articleService.updateByPrimaryKeySelective(article);
			
			SmartSupportRelate support=new SmartSupportRelate();
			
			support.setSid(UUIDUtil.getUUID());
			support.setUserId(userId);
			support.setBusinessId(articleId);
			supportRelateMapper.insert(support);
			return new JsonResult(true, "成功");
		}
		
		if(su==-1)
		{
			  
			SmartArtcile article=articleService.selectByPrimaryKey(articleId);
			
			if(article==null)
			{
				return new JsonResult(false, "该课程不存在");
			}
			int supportNum=article.getSupportNum()+su;
			
			if(supportNum<=0)
			{
				supportNum=0;
			}
			 article.setSupportNum(supportNum);	
		     articleService.updateByPrimaryKeySelective(article);
		      SmartSupportRelateExample  sre=new SmartSupportRelateExample();
			  sre.createCriteria().andBusinessIdEqualTo(articleId).andUserIdEqualTo(userId);
			  supportRelateMapper.deleteByExample(sre);
			
		}
		
		return new JsonResult(false, "参数错误");
	}
	
	
	

	/**
	 * 已审核的文章列表
	 * @param start
	 * @param pageSize
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/queryedArticleList",method = RequestMethod.POST)
	public JsonResult queryedArticleList(HttpServletRequest request,String teacherId){
		int start=1;
		if(StringUtil.isNotEmpty(request.getParameter("start")))
		{
		  start=Integer.valueOf(request.getParameter("start").toString());
		}
		
		int pageSize=8;
		if(StringUtil.isNotEmpty(request.getParameter("pageSize")))
		{
			pageSize=Integer.valueOf(request.getParameter("pageSize").toString());
		}
		int begin =pageSize*(start-1);
		
		Pagination<SmartArtcile> artcilePageInfo= articleService.queryTeacherArticleList(begin, pageSize, "2", teacherId);
		Map<String,Object> resultMap=new HashMap<String, Object>();
		resultMap.put("artcileList", artcilePageInfo.getDataList());
		resultMap.put("sumRow", artcilePageInfo.getTotalRowNumber());
		return new JsonResult(true, "成功", resultMap);
	 
	}
	
	

	/**
	 * 未审核的文章列表
	 * @param start
	 * @param pageSize
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/queryNoArticleList",method = RequestMethod.POST)
	public JsonResult queryNoArticleList(HttpServletRequest request,String teacherId){
		int start=1;
		if(StringUtil.isNotEmpty(request.getParameter("start")))
		{
		  start=Integer.valueOf(request.getParameter("start").toString());
		}
		
		int pageSize=8;
		if(StringUtil.isNotEmpty(request.getParameter("pageSize")))
		{
			pageSize=Integer.valueOf(request.getParameter("pageSize").toString());
		}
		int begin =pageSize*(start-1);
		
		Pagination<SmartArtcile> artcilePageInfo= articleService.queryTeacherArticleList(begin, pageSize, "0", teacherId);
		Map<String,Object> resultMap=new HashMap<String, Object>();
		resultMap.put("artcileList", artcilePageInfo.getDataList());
		resultMap.put("sumRow", artcilePageInfo.getTotalRowNumber());
		return new JsonResult(true, "成功", resultMap);
	 
	}
	
	
	/**
	 * 老师文章列表
	 * @param start
	 * @param pageSize
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/queryUserArticleList",method = RequestMethod.POST)
	public JsonResult queryUserArticleList(HttpServletRequest request,String teacherId,String checkStatus,String categroyCode,String source){
		int start=1;
		if(StringUtil.isNotEmpty(request.getParameter("start")))
		{
		  start=Integer.valueOf(request.getParameter("start").toString());
		}
		
		int pageSize=8;
		if(StringUtil.isNotEmpty(request.getParameter("pageSize")))
		{
			pageSize=Integer.valueOf(request.getParameter("pageSize").toString());
		}
		int begin =pageSize*(start-1);
		
		Pagination<SmartArtcile> artcilePageInfo= articleService.queryTeacherArticleList(begin, pageSize, checkStatus, teacherId,categroyCode,source);
		Map<String,Object> resultMap=new HashMap<String, Object>();
		resultMap.put("artcileList", artcilePageInfo.getDataList());
		resultMap.put("sumRow", artcilePageInfo.getTotalRowNumber());
		return new JsonResult(true, "成功", resultMap);
	 
	}

	/**
	 * 待审核的文章列表
	 * @param start
	 * @param pageSize
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/queryingArticleList",method = RequestMethod.POST)
	public JsonResult queryingArticleList(HttpServletRequest request,String teacherId){
		int start=1;
		if(StringUtil.isNotEmpty(request.getParameter("start")))
		{
		  start=Integer.valueOf(request.getParameter("start").toString());
		}
		
		int pageSize=8;
		if(StringUtil.isNotEmpty(request.getParameter("pageSize")))
		{
			pageSize=Integer.valueOf(request.getParameter("pageSize").toString());
		}
		int begin =pageSize*(start-1);
		
		Pagination<SmartArtcile> artcilePageInfo= articleService.queryTeacherArticleList(begin, pageSize, "1", teacherId);
		Map<String,Object> resultMap=new HashMap<String, Object>();
		resultMap.put("artcileList", artcilePageInfo.getDataList());
		resultMap.put("sumRow", artcilePageInfo.getTotalRowNumber());
		return new JsonResult(true, "成功", resultMap);
	 
	}
	
	
	/**
	 * 查询列表
	 * @param start
	 * @param pageSize
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/manager/queryArticleList",method = RequestMethod.POST)
	public JsonResult queryManagerArticleList(HttpServletRequest request,String site,String articleName,String status,String arcticleCategroy){
		int start=1;
		if(StringUtil.isNotEmpty(request.getParameter("start")))
		{
		  start=Integer.valueOf(request.getParameter("start").toString());
		}
		
		int pageSize=8;
		if(StringUtil.isNotEmpty(request.getParameter("pageSize")))
		{
			pageSize=Integer.valueOf(request.getParameter("pageSize").toString());
		}
		int begin =pageSize*(start-1);
		
		Pagination<SmartArtcile> artcilePageInfo= articleService.queryManageArticleList(begin, pageSize, site, articleName, status,arcticleCategroy);
		Map<String,Object> resultMap=new HashMap<String, Object>();
		resultMap.put("artcileList", artcilePageInfo.getDataList());
		resultMap.put("sumRow", artcilePageInfo.getTotalRowNumber());
		return new JsonResult(true, "成功", resultMap);
	 
	}
	
	
	
	
	
	/**
	 *  文章审核
	 * @param start
	 * @param pageSize
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/manger/updateArticle",method = RequestMethod.POST)
	public JsonResult updateMangerArticleStatus(HttpServletRequest request,String arcId,String status,String comment,HttpServletResponse  response){
		response.setHeader("Access-Control-Allow-Origin", "*");
		response.setHeader("Access-Control-Allow-Methods", "POST");
		
		
		SmartArtcile article= articleService.selectByPrimaryKey(arcId);
		if(article==null)
		{
			return new JsonResult(false, "该文章不存在");
		}
		
		article.setCheckStatus(status);
		article.setComment(comment);
		articleService.updateByPrimaryKeySelective(article);
		
		 return new JsonResult(true, "修改成功");
	}

	
	/**
	 *  文章审核
	 * @param start
	 * @param pageSize
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/manger/queryArticleDetail",method = RequestMethod.POST)
	public JsonResult queryArticleDetail(HttpServletRequest request,String arcId,HttpServletResponse  response){
		response.setHeader("Access-Control-Allow-Origin", "*");
		response.setHeader("Access-Control-Allow-Methods", "POST");
		SmartArtcile article=articleService.selectByPrimaryKey(arcId);
		if(article==null)
		{
			return new JsonResult(false, "该文章不存在");
		}
		SmartUser user=userService.selectByPrimaryKey(article.getUserSid());
		
		Map<String,Object> dataMap=new HashMap<String, Object>();
		dataMap.put("article", article);
		dataMap.put("smartUser", user);
		return new JsonResult(true, "成功",dataMap);
	}
	
	
	

	/**
	 *  文章是否置顶
	 * @param start
	 * @param pageSize
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/manger/updateArticleSite")
	public JsonResult updateMangerCourseStatus(HttpServletRequest request,String articleId,String site,HttpServletResponse  response){
		response.setHeader("Access-Control-Allow-Origin", "*");
		response.setHeader("Access-Control-Allow-Methods", "POST");
		
		SmartArtcile article= articleService.selectByPrimaryKey(articleId);
		if(article==null)
		{
			return new JsonResult(false, "该课程不存在");
		}
		
		article.setArticleSite(site);
		articleService.updateByPrimaryKeySelective(article);
		
		 return new JsonResult(true, "修改成功");
	}
	
	
	/**
	 * 查询列表
	 * @param start
	 * @param pageSize
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/queryTypeArticleList",method = RequestMethod.POST)
	public JsonResult queryTypeArticleList(HttpServletRequest request){
		int start=1;
		if(StringUtil.isNotEmpty(request.getParameter("start")))
		{
		  start=Integer.valueOf(request.getParameter("start").toString());
		}
		
		int pageSize=5;
		if(StringUtil.isNotEmpty(request.getParameter("pageSize")))
		{
			pageSize=Integer.valueOf(request.getParameter("pageSize").toString());
		}
		int begin =pageSize*(start-1);
		
		SmartArtcileExample exa1=new SmartArtcileExample();
		exa1.createCriteria().andArticleCategoryCodeLike("400101%").andCheckStatusEqualTo("2");
		Pagination<SmartArtcile> page101Info= articleService.queryByPage(exa1, begin, pageSize," create_time desc");
		SmartArtcileExample exa2=new SmartArtcileExample();

		exa2.createCriteria().andArticleCategoryCodeLike("400102%").andCheckStatusEqualTo("2");
		Pagination<SmartArtcile> pageI102nfo= articleService.queryByPage(exa2, begin, pageSize," create_time desc");
		SmartArtcileExample exa3=new SmartArtcileExample();
		exa3.createCriteria().andArticleCategoryCodeLike("400103%").andCheckStatusEqualTo("2");
		Pagination<SmartArtcile> page103Info= articleService.queryByPage(exa3, begin, pageSize," create_time desc");
		SmartArtcileExample exa4=new SmartArtcileExample();
		exa4.createCriteria().andArticleCategoryCodeLike("400104%").andCheckStatusEqualTo("2");
		Pagination<SmartArtcile> page104Info= articleService.queryByPage(exa4, begin, pageSize," create_time desc");
		
		Map<String,Object> resultMap=new HashMap<String, Object>();
		resultMap.put("lastList", page101Info.getDataList());
		resultMap.put("softList", pageI102nfo.getDataList());
		resultMap.put("hardwareList", page103Info.getDataList());
		resultMap.put("ueList", page104Info.getDataList());
		return new JsonResult(true, "成功", resultMap);
	 
	}
	
	
	/**
	 * 保存
	 * @param entity
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "manager/save",method = RequestMethod.POST)
	public JsonResult saveManageEntity(HttpServletRequest request,HttpServletResponse response, SmartArtcile entity,String mainCode,String subCode){
		
		response.setHeader("Access-Control-Allow-Origin", "*");
		response.setHeader("Access-Control-Allow-Methods", "POST");
		
		SysCourseCategoryExample  caExa=new SysCourseCategoryExample();
		Criteria cateCri=caExa.createCriteria();
		if(StringUtil.isEmpty(subCode))
		{
			
			return new JsonResult(true,"类目不能为空");
		}
		cateCri.andTextEqualTo(subCode);

		List<SysCourseCategory> cateList= sysCourseService.selectByExample(caExa);
		if(cateList.isEmpty())
		return new JsonResult(true,"类目无效");
		
		
		
		SysCourseCategoryExample  caExa1=new SysCourseCategoryExample();
		Criteria cateCri1=caExa1.createCriteria();
		if(StringUtil.isEmpty(mainCode))
		{
			
			return new JsonResult(true,"类目不能为空");
		}
		cateCri1.andValueEqualTo(mainCode);

		List<SysCourseCategory> cate1List= sysCourseService.selectByExample(caExa1);
		if(cate1List.isEmpty())
		return new JsonResult(true,"类目无效");
		
		
		
		entity.setArticleCategoryCode(cateList.get(0).getValue());
		entity.setArticleCategory(cate1List.get(0).getText()+">"+cateList.get(0).getText());
	
		try {
			entity.setCheckStatus("1");
			if(StringUtil.isEmpty(entity.getSid()))
			{  
				
				entity.setSid(UUIDUtil.getUUID());
				entity.setUserSid("1");
				entity.setTeacherId("1");
				entity.setArticleSite("0");
				entity.setStudyNum("0");
				entity.setUserName("管理员");
				entity.setSupportNum(0);
				entity.setCreateTime(new Date());
				entity.setModifyTime(new Date());
				articleService.insert(entity);
			}else
			{
				articleService.updateByPrimaryKeySelective(entity);
			}
			
			return new JsonResult(true,"操作成功");
		} catch (Exception e) {
			return new JsonResult(false,e.getMessage());
		}
	}
	

	/**
	 * 编辑
	 * @param entity
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "manager/detail",method = RequestMethod.POST)
	public JsonResult articleManagedetail(HttpServletRequest request,HttpServletResponse response,String sid){
		
		response.setHeader("Access-Control-Allow-Origin", "*");
		response.setHeader("Access-Control-Allow-Methods", "POST");
		
	    SmartArtcile article=articleService.selectByPrimaryKey(sid);
	    
	    if(article==null)
	    {
	    	 return new JsonResult(true,"文章不存在");
	    }
	    
	    SysCourseCategoryExample  caExa=new SysCourseCategoryExample();
		Criteria cateCri=caExa.createCriteria();
	
		cateCri.andValueEqualTo(article.getArticleCategoryCode());

		List<SysCourseCategory> cateList= sysCourseService.selectByExample(caExa);
		if(cateList.isEmpty())
		return new JsonResult(true,"类目无效");
		
		article.setMainCode(cateList.get(0).getParentCode());
		article.setSubCode(cateList.get(0).getText());
		
		 return new JsonResult(true,article);
		
	}
	
	/**
	 * 保存
	 * @param entity
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/save",method = RequestMethod.POST)
	public JsonResult saveEntity(HttpServletRequest request, SmartArtcile entity){
		
     SmartUser currentUser=CommonUtil.getCurrentUser(request);
		
		if(currentUser==null)
		{
			JsonResult jsonResult = new JsonResult(false, "登录失效,请先登录之后再发布课程！");
			jsonResult.setCode("5001");
			return jsonResult;
		}
		
		try {
			entity.setCheckStatus("1");
			if(StringUtil.isEmpty(entity.getSid()))
			{  
				
				entity.setSid(UUIDUtil.getUUID());
				entity.setUserSid(currentUser.getSid());
				entity.setTeacherId(currentUser.getSid());
				entity.setArticleSite("0");
				entity.setStudyNum("0");
				entity.setCreateTime(new Date());
				entity.setModifyTime(new Date());
				articleService.insert(entity);
			}else
			{
				entity.setArticleSite("0");
				articleService.updateByPrimaryKeySelective(entity);
			}
			
			return new JsonResult(true,"操作成功");
		} catch (Exception e) {
			return new JsonResult(false,e.getMessage());
		}
	}
	
	
	
	
	/**
	 * 删除banner图片接口
	 * @param pickey
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/deleteBannerImg",method = RequestMethod.POST)
	public JsonResult deleteBannerImg(String pickey){
		
		ossService.delete(OssConstant.NAMESPACE_BUSINESS,pickey);
		return new JsonResult(true, "删除成功!");
	}
	
	/**
	 * 编辑
	 */
	@ResponseBody
	@RequestMapping(value = "/update",method = RequestMethod.POST)
	public JsonResult updateEntity(SmartArtcile entity) {
		try {
			articleService.updateByPrimaryKeySelective(entity);
			return new JsonResult(true,"操作成功");
		} catch (Exception e) {
			return new JsonResult(false,e.getMessage());
		}
	}
	
	/**
	 * 查询
	 * @param id
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/queryDetail",method = RequestMethod.POST)
	public JsonResult queryEntity(String sid){
		try {
			return new JsonResult(true,articleService.selectByPrimaryKey(sid));
		} catch (Exception e) {
			return new JsonResult(false,e.getMessage());
		}
	}
	
	
	/**
	 * 查询文章详情
	 * @param id
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/queryArticleDetail",method = RequestMethod.POST)
	public JsonResult queryEntity(String sid,String userId){
		try {
			Map<String,Object> resultMap=new HashMap<String, Object>();
		    SmartArtcile article=articleService.selectByPrimaryKey(sid);
		    List<SmartSupportRelate> list= new ArrayList<SmartSupportRelate>();
		   if(StringUtil.isNotEmpty(userId))
		    {
		    	  SmartSupportRelateExample  sre=new SmartSupportRelateExample();
				  sre.createCriteria().andBusinessIdEqualTo(sid).andUserIdEqualTo(userId);
				  list= supportRelateMapper.selectByExample(sre);
		    }
		   if(list.isEmpty())
			  {
				  resultMap.put("articleSupport", 0);
			  }else
			  {
				  resultMap.put("articleSupport",1);
			  }
		    resultMap.put("article", article);
			return new JsonResult(true,resultMap);
		} catch (Exception e) {
			return new JsonResult(false,e.getMessage());
		}
	}
	
	/**
	 * 删除
	 * @param ids
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/delete",method = RequestMethod.POST)
	public JsonResult deleteEntities(String sid){
		try {
			articleService.deleteByPrimaryKey(sid);
			return new JsonResult(true,"操作成功");
		} catch (Exception e) {
			return new JsonResult(false,e.getMessage());
		}
	}

	
}
